#$ARGV[0] is the RSSI model log file.
#$ARGV[1] is the number of channel that you want increase the noise floor.
#$ARGV[2] is the number of RSSI you want to increase.
#$ARGV[3] is the number of records that you want to process.

$file = $ARGV[0];
$channel=1;
$increasedRssi = -8;
if($ARGV[1]!=0){
	$channel = $ARGV[1];
}
if($ARGV[2]!=0){
	$increasedRssi = $ARGV[2];
}
$totalNum = 1000000000;
if($ARGV[2]!=0){
	$totalNum = $ARGV[3];
}


@pathname = split(/\\/,$file);
$len = @pathname;
$path;
print "$len\n";
for($i=$len-2;$i>=0;$i--){
	$path = "$pathname[$i]\\"."$path";
	print "$path\n";
}

$channelNum = 16;
@samples;
# for($i=0;$i<$totalNum;$i++){
	# for($j=0;$j<$channelNum+1;$j++) {
		# $samples[$i][$j] = 0;
	# }
# }

#get the samples from log file
$alreadyNum = 0;
open fin, "<$file" or die "can not open file $file!\n";
open fout, ">$path\\totalSyncModifiedC$channel.dat" or die "can not open file .\\totalSyncModifiedC$channel.dat\n";
GETSAMPLE:{
	while (<fin>) {
		chomp;
		@info = split;
		
		for($i=0;$i<$channelNum+1;$i++){
			if($i==0){
				print fout "$info[$i] ";
			}
			else{
				if($i==$channel) {
					$temp = $info[$i]+$increasedRssi;
					print fout "$temp ";
				}
				else{
					print fout "$info[$i] ";
				}
			}
		}
		print fout "\n";
		$alreadyNum++;
		print "$alreadyNum\n";
		if($alreadyNum==$totalNum){
			last GETSAMPLE;
		}
	}
}
close fin;
close fout;


